

class DModule {
    private static _evti = 1;
    private static _evts = {};
    private static _ctrls:DBaseCtrl[] = [];

    public static setStartE(i:number){
        this._evti = i;
    }

    public static register(m:DBaseModule){
        let evts = m.getEvents();
        for(let i in evts){
            let obj = evts[i];
            this._evts[obj.prototype.__class__] = obj;
        }

        let ctrls = m.getCtrls();
        for(let i in ctrls){
            this._ctrls.push(ctrls[i]);
        }
    }

    public static startup(){
        for(let name in this._evts){
            let obj = this._evts[name];
            for (let k in obj){
                obj[k] = this._evti ++;
            }
        }

        for(let i in this._ctrls){
            let c = this._ctrls[i];
            c.init();
        }

        for(let i in this._ctrls){
            let c = this._ctrls[i];
            c.execute();
        }
    }
}